package com.example.administrator.yuejian23.Activity;

import android.content.Context;
import android.os.Bundle;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.yuejian23.Bean.AboutYuejian;
import com.example.administrator.yuejian23.Const;
import com.example.administrator.yuejian23.R;
import com.example.administrator.yuejian23.Retrofit.RetrofitService;
import com.example.administrator.yuejian23.adapter.AboutYuejianAdapter;
import com.squareup.picasso.Picasso;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by Administrator on 2017/10/16.
 */

public class AboutYuejianActivity extends BaseActivity {
    private TextView YuejianNameView;
    private TextView contact;
    private Button backButton;
    private ImageView Image_logo;
    AboutYuejianAdapter aboutYuejianAdapter;
    private AboutYuejian About;
    private Context context;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.item_yuejian_about);

      /*  OnClick();*/
      /*  String address =  About.getLogo();*/
        String text_corpname=getIntent().getStringExtra("text_corpname");
        String text_contact=getIntent().getStringExtra("text_contact");
        String image_logo=getIntent().getStringExtra("Image_logo");
        YuejianNameView= (TextView) findViewById(R.id.text_corpname);
        contact= (TextView) findViewById(R.id.text_contact);
        Image_logo= (ImageView) findViewById(R.id.Image_logo);
       /* Picasso.with(context)
                .load(image_logo)
                .into(Image_logo);*/
        Retrofit retrofit=new Retrofit.Builder().baseUrl(Const.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create()).build();
        RetrofitService service=retrofit.create(RetrofitService.class);
        retrofit2.Call<AboutYuejian> call=service.getYuejian();
        call.enqueue(new Callback<AboutYuejian>() {
            @Override
            public void onResponse(Call<AboutYuejian> call, Response<AboutYuejian> response) {
                About=response.body();
                contact.setText(About.getContact());
                YuejianNameView.setText(About.getCorpname());
              /*  Picasso.with(context).load(About.getLogo()).into(Image_logo);*/
                if (!About.getLogo().equals("")){
                    Picasso.with(AboutYuejianActivity.this).load(About.getLogo()).into(Image_logo);
                }else {
                    Picasso.with(context).load(R.mipmap.ic_myphoto).into(Image_logo);
                }
            }

            @Override
            public void onFailure(Call<AboutYuejian> call, Throwable t) {

            }
        });



    }




    /*private void OnClick() {
        backButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(AboutYuejianActivity.this, MyFragment.class);
                startActivity(intent);
            }
        });*/
    }

